qlm

Read about qlm, The latest news, videos, and discussion topics about qlm from alibabacloud.com

Segment Tree (petition version)

Personal feeling a little bit pitAdd tags are permanentlyThe tag used for set is passed#include #include#include#include#defineLson o#defineRson (o#defineLS o#defineRS (ousing namespacestd;Const intn=1e4,inf=1e9;intminv[n2],maxv[n2],sumv[n2];intaddv[n2],setv[n2];intql,qr,p,v;// PointintQuerymin (intOintLintR) { intm=l+ (r-l) >>1), ans=INF; if(QLreturnMinv[o]; if(qlmin (ans,querymin (Lson)); if(m+1min (ans,querymin (Rson)); returnans;}voidChangeintOintLintR) { intm=l+ (r-l) >>1); if(l==r) M

Bzoj 3626: [LNOI2014]LCA [Tree chain Split Line | Chairman Tree]

];inlinevoidMergeinto) {T[o].sum=t[lc].sum+T[rc].sum;} InlinevoidPaintintOintLintRintd) {T[o].sum+=d* (r-l+1); T[o].add+=D;} InlinevoidPushdown (intOintLintR) { if(t[o].add) {paint (Lson,t[o].add); Paint (Rson,t[o].add); T[o].add=0; }}inlinevoidSegadd (intOintLintRintQlintQrintD) {//printf ("Add%d%d%d\n", o,l,r); if(qlqr) paint (o,l,r,d); Else{pushdown (o,l,r); if(qlm) Segadd (LSON,QL,QR,D); if(mqr) segadd (rson,ql,qr,d); Merge (o); }}

Bzoj 2243: [SDOI2011] staining [tree-chain split]

].tag); Paint (Rc,t[o].tag); T[o].tag=-1; }}voidChangeintOintLintRintQlintQrintv) { if(qlqr) paint (o,v); Else{pushdown (o); if(qlm) Change (LSON,QL,QR,V); if(mqr) change (rson,ql,qr,v); Merge (o); }}intQueryintOintLintRintQlintqr) { if(QLreturnt[o].cnt; Else if(t[o].tag!=-1)return 1; Else{pushdown (o); intans=0; if(qlquery (LSON,QL,QR); if(Mquery (RSON,QL,QR); if(ql; returnans; }}intGetcol (intOintLintRintp) { if(L==R)returnt[o].lv

POJ 1007 WZJ Data Structure (vii) operations on the tree

]; - } -}return; - } - voidBuildintUintTP) { -num[u]=++sz;top[u]=TP; in if(Son[u]) build (SON[U],TP); - for(intI=fch[u];i;i=Adj[i].next) { to intv=adj[i].y; + if(v!=fa[u]v!=Son[u]) build (v,v); -}return; the } * voidUpdateintOintLintR) { $ if(QLCV;Panax Notoginseng Else{ - intM=l+r>>1,lc=o1, rc=lc|1; the if(qlM) Update (LC,L,M); + if(qr>m) Update (rc,m+1, R); A}return; the } + voidChange

A simple problem with integers

(qlqr) {Add[i]+=Val; Sum[i]+ = (ll) val* (r-l+1); return ; } pushdown (I,r-l+1); intM= (L+R)/2; if(qlm) update (Ql,qr,val,lson); if(mqr) update (Ql,qr,val,rson); Pushup (i);} ll query (intQlintQrintIintLintR) { //cout if(qlqr) { returnSum[i]; } pushdown (I,r-l+1); intM= (L+R)/2; LL cur=0; if(qlquery (Ql,qr,lson); if(Mquery (Ql,qr,rson); returncur;}intMain () {//freopen ("C:\\users\\acer\\desktop\\in.txt", "R", stdin); intn,q; Charop;

"Line segment Tree" bzoj3747 [Poi2015]kinoman

Puzzle: http://www.cnblogs.com/zyfzyf/p/4105184.html1#include 2#include 3#include 4 using namespacestd;5 #defineLson rt6 #defineRson Rt7 intnum,ch[ A],f,c;8InlinevoidRintx) {9C=0; f=1;Ten for(;c'0'|| C>'9'; C=getchar ())if(c=='-') f=-1; One for(x=0; c>='0'c'9'; C=getchar ()) (x*=Ten) + = (c'0'); Ax*=F; - } -typedefLong Longll; the intn,m,w[1000001],now[1000001],b[1000001],fa[1000001]; -ll ans,maxv[4000001],delta[4000001]; - voidPushdown (intRT) - { + if(Delta[rt]) - { +delta[

Medium POJ 1436 horizontally Visible segments, segment tree + interval update.

afternoon, just beginning to set COL to bool variable, the result ... T, has not found the error to ... Pain... ) code is as follows:#include #include#include#include#defineLson l,m,po*2#defineRson m+1,r,po*2+1using namespacestd;Const intn=8000*2;intcol[8008*2*4];BOOLmap1[8008][8008];voidPushdown (intPO) { if(col[po]>=0) {Col[po*2]=col[po*2+1]=Col[po]; COL[PO]=-1; }}voidUpdateintUlinturintUtintLintRintPO) { if(ulR) {Col[po]=ut; return; } pushdown (PO); intM= (L+R)/2; if(ulM) Update (Ul

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.